<template>
	<view class="container-box">
		<u-cell-group>
			<u-cell icon="account" title="客户姓名" :value="info.customerName"></u-cell>
			<u-cell icon="phone" title="客户手机号" :value="info.phone"></u-cell>
			<u-cell icon="pushpin-fill" title="预约门店" :value="info.appointStoreName"></u-cell>
			<u-cell icon="calendar" title="预约时间" :value="info.appointTime"></u-cell>
			<u-cell icon="calendar" title="班次" :value="info.scheduleType"></u-cell>
			<u-cell icon="setting" title="预约科室" :value="info.appointDeptName"></u-cell>
			<u-cell icon="account" title="医生" :value="info.doctorName"></u-cell>
			<u-cell icon="account" title="预约状态" :value="info.appointText"></u-cell>
		</u-cell-group>
		<view style="padding: 20rpx 50rpx;">
			<u-button v-if="info.appointStatus === 1" text="取消预约" color="#2E75E8" type="info"
				@click="cancelMethod(info)"></u-button>
			<evaluateComplate v-if="info.appointStatus === 2" :appointStoreId="info.appointStoreId"
				:doctorId="info.doctorId" :kid="info.id">
			</evaluateComplate>
		</view>
	</view>
</template>
<script>
	import {
		appointRecordInfo
	} from "@/api/axios/Message.js";
	import {
		cancelAppoint
	} from "@/api/axios/MakeAnAppointmentCenter.js";
	import evaluateComplate from "./evaluateComplate/index.vue";

	export default {
		props: {
			detailId: {
				type: String,
			},
			appointPushRecordId: {
				type: String,
			},
		},
		components: {
			evaluateComplate
		},
		data() {
			return {
				info: {},
			};
		},
		methods: {
			cancelMethod(item) {
				cancelAppoint({
					id: item.id,
					consultantId: item.customerId,
					triageType: item.appointType,
				}).then((res) => {
					uni.showToast({
						icon: "none",
						title: "取消预约成功",
						duration: 1000,
					});
					setTimeout(() => {
						uni.redirectTo({
							url: "/pages/Main/index",
						});
					}, 1000);
				});
			},
		},
		mounted() {
			let openId = uni.getStorageSync("openId");
			let customerId = uni.getStorageSync("customerId");
			appointRecordInfo({
				params: {
					id: this.detailId,
					openId,
					appointPushRecordId: this.appointPushRecordId,
					customerId,
				},
			}).then((res) => {
				if (res.scheduleType === 1) {
					res.scheduleType = "上午";
				} else if (res.scheduleType === 2) {
					res.scheduleType = "下午";
				} else if (res.scheduleType === 3) {
					res.scheduleType = "晚上";
				}

				if (res.appointStatus === 1) {
					res.appointText = "已预约";
				} else if (res.appointStatus === 2) {
					res.appointText = "已分诊";
				} else if (res.appointStatus === 3) {
					res.appointText = "取消预约";
				}
				this.info = res;
				console.log(this.info);
			});
		},
	};
</script>
<style lang="scss" scoped>
</style>